In [1]:
import rhkpy
import numpy as np

Importing some data, from our previous publication in Science Advances. The raw data is available here: doi.org/10.6084

Loading data¶

In [2]:
# path to a dIdV map
datapath_map = r'C:\Users\zrbyt\OneDrive - energia.mta.hu\Documents\work_MFA\cikkek - published\2022\RG magnetism\figures\splitting' + '\\'
filename_didvmap = '9K_ABC6_2020_11_02_08_47_19_209.sm4'
# spectra across a line
datapath_line = r'C:\Users\zrbyt\OneDrive - energia.mta.hu\Documents\work_MFA\cikkek - published\2022\RG magnetism\figures\intro\line spec_peak shift' + '\\'
filename_line = '9K_ABC6_2020_11_01_12_12_27_213.sm4'
# single spectra
datapath_spec = r'C:\Users\zrbyt\OneDrive - energia.mta.hu\Documents\work_MFA\cikkek - published\2022\RG magnetism\figures\intro\spectra' + '\\'
filename_spec1 = r'dI-dV_9K_ABC6_2020_10_17_13_54_34_531.sm4'
filename_spec2 = r'dI-dV_9K_ABC6_2020_11_01_21_03_19_089.sm4'

Let's load the spectra, using rhkpy. The sm4 files are loaded into instances of an rhkdata class. Documentation can be found here: github.io/rhkpy

In [3]:
didvmap = rhkpy.rhkdata(datapath_map + filename_didvmap)
linespec = rhkpy.rhkdata(datapath_line + filename_line)
spec1 = rhkpy.rhkdata(datapath_spec + filename_spec1)
spec2 = rhkpy.rhkdata(datapath_spec + filename_spec2)

Plotting¶

We can now use the qplot() "quick plot" method of each rhkdata object to take a look at the data.

In [4]:
didvmap.qplot()
Out[4]:
In [5]:
linespec.qplot()
Out[5]:
In [6]:
spec1.qplot()
Out[6]:

"Navigation"¶

Let's see how the data were measured, in relation to each other. This can be very helpful in data analysis. For this we can use the navigation() method.

In [7]:
rhkpy.navigation(didvmap, linespec, spec1, spec2)
Out[7]:

We can see that spec1, or the spectrum "...531.sm4" was measured far from the map. Let's replot, without this one.

In [8]:
rhkpy.navigation(didvmap, linespec, spec2)
Out[8]:

The above plot, shows the topgraphy data in the didvmap, as well as the spectrum positions of the map. In green we can see the spectrum positions of the "line spectrum" and in red, the positions of the single spectrum.

The rhkdata class by default places a flatten filter on the topography data. We can prevent this and load the raw data by using the keyword: loadraw = True. Let's try this.

In [9]:
didvmap_raw = rhkpy.rhkdata(datapath_map + filename_didvmap, loadraw = True)
In [10]:
didvmap_raw.qplot()
Out[10]:

Let's plot the topography and current datasets from didvmap.

In [11]:
didvmap.image.topography.sel(scandir = 'backward').hvplot(cmap = 'fire')
Out[11]:
In [12]:
didvmap.image.current.sel(scandir = 'backward').hvplot(cmap = 'plasma')
Out[12]:

Peak fitting to spectroscopy data¶

Let's take a look at the spectra in the didvmap. This rhkdata instance, containing a map has two xarray variables:

  • image
  • spectra As we've seen above, the images are contained in the didvmap.image variable. Let's take a look at the 'didvmap.spectra' variable.

First, let's plot one of the spectra.

In [13]:
didvmap.spectra
Out[13]:
<xarray.Dataset>
Dimensions:      (bias: 201, specpos_y: 64, specpos_x: 64, repetitions: 1,
                  biasscandir: 2)
Coordinates:
  * bias         (bias) float64 0.2 0.198 0.196 0.194 ... -0.196 -0.198 -0.2
  * specpos_x    (specpos_x) float64 6.307 5.057 3.807 ... -69.94 -71.19 -72.44
  * specpos_y    (specpos_y) float64 -119.9 -121.1 -122.4 ... -197.4 -198.6
  * repetitions  (repetitions) int32 0
  * biasscandir  (biasscandir) <U5 'left' 'right'
Data variables:
    lia          (bias, specpos_y, specpos_x, repetitions, biasscandir) float64 ...
    current      (bias, specpos_y, specpos_x, repetitions, biasscandir) float64 ...
    x            (specpos_y, specpos_x) float64 6.307 5.057 ... -71.19 -72.44
    y            (specpos_y, specpos_x) float64 -119.9 -119.9 ... -198.6 -198.6
Attributes: (12/15)
    filename:           9K_ABC6_2020_11_02_08_47_19_209.sm4
    bias:               0.49999973
    bias units:         V
    setpoint:           99.99999439624929
    setpoint units:     pA
    measurement date:   11/01/20
    ...                 ...
    LI amplitude unit:  mV
    LI frequency:       1300.0
    LI frequency unit:  Hz
    LI phase:           -102.9999998
    datatype:           map
    spectype:           iv
xarray.Dataset
    • bias: 201
    • specpos_y: 64
    • specpos_x: 64
    • repetitions: 1
    • biasscandir: 2
    • bias
      (bias)
      float64
      0.2 0.198 0.196 ... -0.198 -0.2
      units :
      V
      array([ 0.2  ,  0.198,  0.196, ..., -0.196, -0.198, -0.2  ])
    • specpos_x
      (specpos_x)
      float64
      6.307 5.057 3.807 ... -71.19 -72.44
      units :
      nm
      long units :
      nanometer
      array([ 6.307008e+00,  5.057007e+00,  3.807006e+00,  2.557009e+00,
              1.307008e+00,  5.700684e-02, -1.192994e+00, -2.442992e+00,
             -3.692993e+00, -4.942994e+00, -6.192993e+00, -7.442992e+00,
             -8.692993e+00, -9.942992e+00, -1.119299e+01, -1.244299e+01,
             -1.369299e+01, -1.494299e+01, -1.619299e+01, -1.744299e+01,
             -1.869299e+01, -1.994299e+01, -2.119299e+01, -2.244299e+01,
             -2.369299e+01, -2.494299e+01, -2.619299e+01, -2.744299e+01,
             -2.869299e+01, -2.994299e+01, -3.119299e+01, -3.244299e+01,
             -3.369299e+01, -3.494299e+01, -3.619299e+01, -3.744299e+01,
             -3.869299e+01, -3.994299e+01, -4.119299e+01, -4.244299e+01,
             -4.369299e+01, -4.494299e+01, -4.619299e+01, -4.744299e+01,
             -4.869299e+01, -4.994299e+01, -5.119299e+01, -5.244299e+01,
             -5.369299e+01, -5.494299e+01, -5.619300e+01, -5.744299e+01,
             -5.869299e+01, -5.994299e+01, -6.119299e+01, -6.244299e+01,
             -6.369299e+01, -6.494299e+01, -6.619300e+01, -6.744300e+01,
             -6.869299e+01, -6.994299e+01, -7.119299e+01, -7.244299e+01])
    • specpos_y
      (specpos_y)
      float64
      -119.9 -121.1 ... -197.4 -198.6
      units :
      nm
      long units :
      nanometer
      array([-119.886053, -121.136054, -122.386055, -123.636056, -124.886043,
             -126.136058, -127.386045, -128.636046, -129.886047, -131.136048,
             -132.386049, -133.63605 , -134.886051, -136.136052, -137.386053,
             -138.636054, -139.886055, -141.136056, -142.386057, -143.636044,
             -144.886044, -146.136045, -147.386046, -148.636047, -149.886048,
             -151.136049, -152.38605 , -153.636051, -154.886052, -156.136053,
             -157.386054, -158.636055, -159.886056, -161.136057, -162.386044,
             -163.636045, -164.886046, -166.136047, -167.386048, -168.636049,
             -169.88605 , -171.136051, -172.386052, -173.636053, -174.886054,
             -176.136055, -177.386056, -178.636043, -179.886058, -181.136045,
             -182.386046, -183.636047, -184.886048, -186.136049, -187.38605 ,
             -188.636051, -189.886052, -191.136053, -192.386054, -193.636055,
             -194.886042, -196.136057, -197.386044, -198.636059])
    • repetitions
      (repetitions)
      int32
      0
      array([0])
    • biasscandir
      (biasscandir)
      <U5
      'left' 'right'
      array(['left', 'right'], dtype='<U5')
    • lia
      (bias, specpos_y, specpos_x, repetitions, biasscandir)
      float64
      1.459 1.565 1.65 ... 1.932 1.856
      units :
      pA
      long units :
      picoampere
      bias :
      0.49999973
      bias units :
      V
      setpoint :
      99.99999439624929
      setpoint units :
      pA
      time_per_point :
      1e-04
      array([[[[[1.45853962, 1.56484078]],
      
               [[1.65041069, 1.60984228]],
      
               [[1.77906359, 1.61787494]],
      
               ...,
      
               [[1.72368715, 1.89152079]],
      
               [[1.52514315, 2.07237432]],
      
               [[1.36368441, 1.50298233]]],
      
      
              [[[1.89792829, 1.5574973 ]],
      
               [[1.85817479, 1.63768883]],
      
               [[1.44280958, 1.7587887 ]],
      ...
               [[2.31366137, 2.42263543]],
      
               [[2.22742556, 2.17387451]],
      
               [[2.3180479 , 2.0276755 ]]],
      
      
              [[[1.79636757, 1.83303374]],
      
               [[1.6077794 , 1.72385014]],
      
               [[1.60352326, 2.00888606]],
      
               ...,
      
               [[2.11530364, 2.37999017]],
      
               [[2.28858551, 2.21018678]],
      
               [[1.93174462, 1.8560374 ]]]]])
    • current
      (bias, specpos_y, specpos_x, repetitions, biasscandir)
      float64
      39.25 39.62 37.29 ... -21.54 -21.1
      units :
      pA
      long units :
      picoampere
      bias :
      0.49999973
      bias units :
      V
      setpoint :
      99.99999439624929
      setpoint units :
      pA
      time_per_point :
      1e-04
      array([[[[[ 39.25443603,  39.61554239]],
      
               [[ 37.28778079,  37.72614035]],
      
               [[ 37.87174798,  39.00208952]],
      
               ...,
      
               [[ 35.89646869,  45.65976067]],
      
               [[ 33.65387188,  39.77688471]],
      
               [[ 31.32132329,  34.92413067]]],
      
      
              [[[ 42.85613515,  38.60163945]],
      
               [[ 37.58792277,  36.57989647]],
      
               [[ 35.37770805,  43.7460092 ]],
      ...
               [[-26.26052576, -25.96569697]],
      
               [[-24.24098071, -23.993668  ]],
      
               [[-22.71851045, -22.65013741]]],
      
      
              [[[-28.05002948, -27.70731209]],
      
               [[-25.52302539, -25.57544953]],
      
               [[-29.29091901, -29.70335521]],
      
               ...,
      
               [[-22.28015089, -22.54216918]],
      
               [[-24.57517184, -24.83523901]],
      
               [[-21.53910218, -21.09728741]]]]])
    • x
      (specpos_y, specpos_x)
      float64
      6.307 5.057 3.807 ... -71.19 -72.44
      units :
      nm
      long units :
      nanometer
      array([[  6.30700825,   5.05700726,   3.80700627, ..., -69.94299184,
              -71.19299283, -72.44299383],
             [  6.30700825,   5.05700726,   3.80700627, ..., -69.94299184,
              -71.19299283, -72.44299383],
             [  6.30700825,   5.05700726,   3.80700627, ..., -69.94299184,
              -71.19299283, -72.44299383],
             ...,
             [  6.30700825,   5.05700726,   3.80700627, ..., -69.94299184,
              -71.19299283, -72.44299383],
             [  6.30700825,   5.05700726,   3.80700627, ..., -69.94299184,
              -71.19299283, -72.44299383],
             [  6.30700825,   5.05700726,   3.80700627, ..., -69.94299184,
              -71.19299283, -72.44299383]])
    • y
      (specpos_y, specpos_x)
      float64
      -119.9 -119.9 ... -198.6 -198.6
      units :
      nm
      long units :
      nanometer
      array([[-119.88605308, -119.88605308, -119.88605308, ..., -119.88605308,
              -119.88605308, -119.88605308],
             [-121.13605408, -121.13605408, -121.13605408, ..., -121.13605408,
              -121.13605408, -121.13605408],
             [-122.38605507, -122.38605507, -122.38605507, ..., -122.38605507,
              -122.38605507, -122.38605507],
             ...,
             [-196.13605673, -196.13605673, -196.13605673, ..., -196.13605673,
              -196.13605673, -196.13605673],
             [-197.38604351, -197.38604351, -197.38604351, ..., -197.38604351,
              -197.38604351, -197.38604351],
             [-198.63605871, -198.63605871, -198.63605871, ..., -198.63605871,
              -198.63605871, -198.63605871]])
    • bias
      PandasIndex
      PandasIndex(Float64Index([ 0.20000000298023224,  0.19800000288523734,  0.19600000279024243,
                     0.19400000269524753,  0.19200000260025263,  0.19000000250525773,
                     0.18800000241026282,  0.18600000231526792,  0.18400000222027302,
                     0.18200000212527812,
                    ...
                    -0.18200001516379416, -0.18400001525878906, -0.18600001535378397,
                    -0.18800001544877887, -0.19000001554377377, -0.19200001563876867,
                    -0.19400001573376358, -0.19600001582875848, -0.19800001592375338,
                    -0.20000001601874828],
                   dtype='float64', name='bias', length=201))
    • specpos_x
      PandasIndex
      PandasIndex(Float64Index([  6.307008248995771,   5.057007257391888,  3.8070062657880044,
                     2.5570088268977997,  1.3070078352939163, 0.05700684369003284,
                    -1.1929941479138506, -2.4429915868040553, -3.6929925784079387,
                     -4.942993570011822,  -6.192992785258866,   -7.44299200050591,
                     -8.692992992109794,  -9.942992207356838, -11.192993198960721,
                    -12.442992414207765, -13.692993405811649, -14.942992621058693,
                    -16.192993612662576,  -17.44299282790962, -18.692993819513504,
                    -19.942993034760548, -21.192992250007592, -22.442993241611475,
                     -23.69299245685852, -24.942991672105563, -26.192992663709447,
                     -27.44299365531333, -28.692992870560374,  -29.94299208580742,
                    -31.192993077411302, -32.442994069015185,  -33.69299150790539,
                     -34.94299249950927,  -36.19299349111316,  -37.44299448271704,
                    -38.692991921607245,  -39.94299291321113,  -41.19299390481501,
                    -42.442991343705216,   -43.6929923353091,  -44.94299332691298,
                     -46.19299431851687,  -47.44299175740707, -48.692992749010955,
                     -49.94299018790116,  -51.19299117950504, -52.442992171108926,
                     -53.69299316271281,  -54.94299415431669,  -56.19299514592058,
                     -57.44299258481078, -58.692990023700986,  -59.94299101530487,
                     -61.19299200690875, -62.442992998512636,  -63.69299399011652,
                      -64.9429949817204,  -66.19299597332429,  -67.44299696492817,
                      -68.6929908511047,  -69.94299184270858,  -71.19299283431246,
                     -72.44299382591635],
                   dtype='float64', name='specpos_x'))
    • specpos_y
      PandasIndex
      PandasIndex(Float64Index([-119.88605308488332,  -121.1360540764872, -122.38605506809108,
                    -123.63605605969497, -124.88604284044413, -126.13605804290273,
                     -127.3860448236519, -128.63604581525578, -129.88604680685967,
                    -131.13604779846355, -132.38604879006743, -133.63604978167132,
                     -134.8860507732752, -136.13605176487908, -137.38605275648297,
                    -138.63605374808685, -139.88605473969074, -141.13605573129462,
                     -142.3860567228985, -143.63604350364767, -144.88604449525155,
                    -146.13604548685544, -147.38604647845932,  -148.6360474700632,
                     -149.8860484616671, -151.13604945327097, -152.38605044487485,
                    -153.63605143647874, -154.88605242808262,  -156.1360534196865,
                     -157.3860544112904, -158.63605540289427, -159.88605639449815,
                    -161.13605738610204,  -162.3860441668512,  -163.6360451584551,
                    -164.88604615005897, -166.13604714166286, -167.38604813326674,
                    -168.63604912487062,  -169.8860501164745,  -171.1360511080784,
                    -172.38605209968227, -173.63605309128616, -174.88605408289004,
                    -176.13605507449392,  -177.3860560660978, -178.63604284684698,
                    -179.88605804930557, -181.13604483005474, -182.38604582165863,
                     -183.6360468132625,  -184.8860478048664, -186.13604879647028,
                    -187.38604978807416, -188.63605077967804, -189.88605177128193,
                     -191.1360527628858,  -192.3860537544897, -193.63605474609358,
                    -194.88604152684275, -196.13605672930134,  -197.3860435100505,
                     -198.6360587125091],
                   dtype='float64', name='specpos_y'))
    • repetitions
      PandasIndex
      PandasIndex(Int64Index([0], dtype='int64', name='repetitions'))
    • biasscandir
      PandasIndex
      PandasIndex(Index(['left', 'right'], dtype='object', name='biasscandir'))
  • filename :
    9K_ABC6_2020_11_02_08_47_19_209.sm4
    bias :
    0.49999973
    bias units :
    V
    setpoint :
    99.99999439624929
    setpoint units :
    pA
    measurement date :
    11/01/20
    measurement time :
    21:29:57
    scan angle :
    0.0
    LI amplitude :
    10.0
    LI amplitude unit :
    mV
    LI frequency :
    1300.0
    LI frequency unit :
    Hz
    LI phase :
    -102.9999998
    datatype :
    map
    spectype :
    iv

Let's plot one of the spectra. We can choose which one, based on it's coordinates: specpos_x, specpos_y, in nanometers.

In [14]:
didvmap.qplot()
Out[14]:
In [15]:
didvmap_spec = didvmap.spectra.sel(specpos_x = -40, specpos_y = -130, method = 'nearest')
didvmap_spec
Out[15]:
<xarray.Dataset>
Dimensions:      (bias: 201, repetitions: 1, biasscandir: 2)
Coordinates:
  * bias         (bias) float64 0.2 0.198 0.196 0.194 ... -0.196 -0.198 -0.2
    specpos_x    float64 -39.94
    specpos_y    float64 -129.9
  * repetitions  (repetitions) int32 0
  * biasscandir  (biasscandir) <U5 'left' 'right'
Data variables:
    lia          (bias, repetitions, biasscandir) float64 1.643 1.615 ... 1.871
    current      (bias, repetitions, biasscandir) float64 32.82 33.48 ... -26.95
    x            float64 -39.94
    y            float64 -129.9
Attributes: (12/15)
    filename:           9K_ABC6_2020_11_02_08_47_19_209.sm4
    bias:               0.49999973
    bias units:         V
    setpoint:           99.99999439624929
    setpoint units:     pA
    measurement date:   11/01/20
    ...                 ...
    LI amplitude unit:  mV
    LI frequency:       1300.0
    LI frequency unit:  Hz
    LI phase:           -102.9999998
    datatype:           map
    spectype:           iv
xarray.Dataset
    • bias: 201
    • repetitions: 1
    • biasscandir: 2
    • bias
      (bias)
      float64
      0.2 0.198 0.196 ... -0.198 -0.2
      units :
      V
      array([ 0.2  ,  0.198,  0.196, ..., -0.196, -0.198, -0.2  ])
    • specpos_x
      ()
      float64
      -39.94
      units :
      nm
      long units :
      nanometer
      array(-39.94299291)
    • specpos_y
      ()
      float64
      -129.9
      units :
      nm
      long units :
      nanometer
      array(-129.88604681)
    • repetitions
      (repetitions)
      int32
      0
      array([0])
    • biasscandir
      (biasscandir)
      <U5
      'left' 'right'
      array(['left', 'right'], dtype='<U5')
    • lia
      (bias, repetitions, biasscandir)
      float64
      1.643 1.615 1.882 ... 1.893 1.871
      units :
      pA
      long units :
      picoampere
      bias :
      0.49999973
      bias units :
      V
      setpoint :
      99.99999439624929
      setpoint units :
      pA
      time_per_point :
      1e-04
      array([[[1.64331402, 1.61509494]],
      
             [[1.88178847, 1.65295786]],
      
             [[1.87254975, 1.80838163]],
      
             [[1.71675811, 1.47729646]],
      
             [[1.67515128, 1.86832621]],
      
             [[1.90212856, 1.69776379]],
      
             [[1.5955232 , 1.88595614]],
      
             [[1.32385641, 1.57485715]],
      
             [[1.56388617, 1.83273106]],
      
             [[1.57984904, 1.54478009]],
      
      ...
      
             [[1.80479604, 1.91156751]],
      
             [[1.98249238, 1.70533544]],
      
             [[1.65989621, 1.61623116]],
      
             [[1.64293683, 1.53201631]],
      
             [[1.65439675, 1.99055298]],
      
             [[1.78982503, 1.75465363]],
      
             [[1.73818319, 1.66345387]],
      
             [[1.78258865, 1.73943582]],
      
             [[1.82115006, 1.76210887]],
      
             [[1.89333687, 1.87142751]]])
    • current
      (bias, repetitions, biasscandir)
      float64
      32.82 33.48 33.57 ... -27.3 -26.95
      units :
      pA
      long units :
      picoampere
      bias :
      0.49999973
      bias units :
      V
      setpoint :
      99.99999439624929
      setpoint units :
      pA
      time_per_point :
      1e-04
      array([[[ 3.28182520e+01,  3.34821360e+01]],
      
             [[ 3.35686279e+01,  3.29481669e+01]],
      
             [[ 3.19531232e+01,  3.30975091e+01]],
      
             [[ 3.20169840e+01,  3.25304827e+01]],
      
             [[ 3.27506194e+01,  3.18163911e+01]],
      
             [[ 3.23158827e+01,  3.12607361e+01]],
      
             [[ 3.19968674e+01,  3.12259698e+01]],
      
             [[ 3.07450023e+01,  3.11442137e+01]],
      
             [[ 3.10457170e+01,  3.11381461e+01]],
      
             [[ 2.95795778e+01,  3.05518413e+01]],
      
      ...
      
             [[-2.44630266e+01, -2.42248083e+01]],
      
             [[-2.49172885e+01, -2.47069400e+01]],
      
             [[-2.57630458e+01, -2.60573531e+01]],
      
             [[-2.57831391e+01, -2.54548852e+01]],
      
             [[-2.64164757e+01, -2.55383689e+01]],
      
             [[-2.47108143e+01, -2.55878967e+01]],
      
             [[-2.49425274e+01, -2.66122770e+01]],
      
             [[-2.54784895e+01, -2.66653298e+01]],
      
             [[-2.64151579e+01, -2.67999757e+01]],
      
             [[-2.73017630e+01, -2.69492714e+01]]])
    • x
      ()
      float64
      -39.94
      units :
      nm
      long units :
      nanometer
      array(-39.94299291)
    • y
      ()
      float64
      -129.9
      units :
      nm
      long units :
      nanometer
      array(-129.88604681)
    • bias
      PandasIndex
      PandasIndex(Float64Index([ 0.20000000298023224,  0.19800000288523734,  0.19600000279024243,
                     0.19400000269524753,  0.19200000260025263,  0.19000000250525773,
                     0.18800000241026282,  0.18600000231526792,  0.18400000222027302,
                     0.18200000212527812,
                    ...
                    -0.18200001516379416, -0.18400001525878906, -0.18600001535378397,
                    -0.18800001544877887, -0.19000001554377377, -0.19200001563876867,
                    -0.19400001573376358, -0.19600001582875848, -0.19800001592375338,
                    -0.20000001601874828],
                   dtype='float64', name='bias', length=201))
    • repetitions
      PandasIndex
      PandasIndex(Int64Index([0], dtype='int64', name='repetitions'))
    • biasscandir
      PandasIndex
      PandasIndex(Index(['left', 'right'], dtype='object', name='biasscandir'))
  • filename :
    9K_ABC6_2020_11_02_08_47_19_209.sm4
    bias :
    0.49999973
    bias units :
    V
    setpoint :
    99.99999439624929
    setpoint units :
    pA
    measurement date :
    11/01/20
    measurement time :
    21:29:57
    scan angle :
    0.0
    LI amplitude :
    10.0
    LI amplitude unit :
    mV
    LI frequency :
    1300.0
    LI frequency unit :
    Hz
    LI phase :
    -102.9999998
    datatype :
    map
    spectype :
    iv

This xarray object still has dimensions of bias, repetitions and biasscandir. Let's plot the lia (dI/dV signal) from the dataset.

In [16]:
didvmap_spec.lia.hvplot.line(x = 'bias')
Out[16]:

Let's fit a double Gaussian to this. For this we will take the mean of the data for the two bias scan directions.

In [17]:
didvmap_spec_mean = didvmap_spec.lia.mean(dim = ['repetitions', 'biasscandir'])
# Let's also sleect the data around the peaks
didvmap_spec_mean = didvmap_spec_mean.sel(bias = slice(0.08, -0.08))

For the fit we will specify some starting values. In this case, the estimated positions of the two Gaussians: 'x01': -0.02, 'x02': 0.02

In [18]:
fit_spec = rhkpy.peakfit(didvmap_spec_mean, func = rhkpy.gaussian2, stval = {'x01': -0.02, 'x02': 0.02}, toplot = True)
Values of starting parameters: 
 {'x01': -0.02, 'x02': 0.02, 'ampl1': 1, 'width1': 0.05, 'ampl2': 1, 'width2': 0.05, 'offset': 0} 

Values of fitted parameters:

x01 : -0.02
ampl1 : 2.46
width1 : 0.02
x02 : 0.02
ampl2 : 2.72
width2 : 0.02
offset : 1.32

We can do this for the whole map, as well. Let's fit a Gaussian.

In [31]:
didvmap_mean = didvmap.spectra.lia.mean(dim = ['repetitions', 'biasscandir'])
didvmap_mean = didvmap_mean.sel(bias = slice(0.08, -0.08))
In [36]:
fit_map = rhkpy.peakfit(
    didvmap_mean,
    func = rhkpy.gaussian,
    stval = {'x0': 0, 'width': 0.03})

Now, we have the fit results for each spectrum position in the map. We can plot these. Let's try to plot the width of the Gaussian.

The groupby option in hvplot, let's us click through the parameters of the function.

In [37]:
fit_map.curvefit_coefficients.hvplot.image(x = 'specpos_x', groupby = 'param', cmap = 'plasma')
Out[37]:

Let's just plot the width.

In [40]:
np.abs(fit_map.curvefit_coefficients.sel(param = 'width')).hvplot.image(x = 'specpos_x', cmap = 'BuRd_r')
Out[40]:
In [ ]: